package com.healtyprj.web;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.nisiken.aws.ses.SESUtils;

public class HealtyServletContextListener implements ServletContextListener {

	private static Timer timer;
	
	public HealtyServletContextListener() {
		super();
	}

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// process nothing
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		// initialize send reminder email
		Date firstFireDate = new Date();
		firstFireDate.setTime(firstFireDate.getTime() + 3000); //3秒後
		
		List<String> to = new ArrayList<String>();
		to.add("nisiken219@gmail.com");
		timer = SESUtils.sendScheduleMail(firstFireDate, 1000 * 60 * 60 * 24, "nisiken219@gmail.com", to, "サンプルメール題名", "サンプル本文。");
	}

	public static Timer getTimer() {
		return timer;
	}

	public static void setTimer(Timer timer) {
		HealtyServletContextListener.timer = timer;
	}
}
